use "SCID_Hong_dic.dta", clear

***********************
* spending regression *
***********************
*==============================
* Table1. Production
*==============================
eststo clear
qui xtreg tspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg espendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country) 
eststo 
qui xtreg sspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg tspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc l.tspendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg espendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc l.espendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc l.hspendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions loggdppc l.sspendingpcl yr_*, fe cluster(country)
eststo 
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex

*==============================
* Table 2. Production (no gdp)
*==============================
eststo clear
qui xtreg tspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions yr_*, fe cluster(country)
eststo 
qui xtreg espendingpcl l.oilrent attempt5 coups5 civilwar5 institutions yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions yr_*, fe cluster(country) 
eststo 
qui xtreg sspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions yr_*, fe cluster(country)
eststo
qui xtreg tspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions l.tspendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg espendingpcl l.oilrent attempt5 coups5 civilwar5 institutions l.espendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions l.hspendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.oilrent attempt5 coups5 civilwar5 institutions l.sspendingpcl yr_*, fe cluster(country)
eststo 
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex
 
*==============================
* Table 3. Exports
*==============================
eststo clear
qui xtreg tspendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg espendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg tspendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc l.tspendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg espendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc l.espendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc l.hspendingpcl yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.oilexport attempt5 coups5 civilwar5 institutions loggdppc l.sspendingpcl yr_*, fe cluster(country)
eststo 
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex

*==================================
* Table 4. Reserves
*==================================
eststo clear
qui xtreg tspendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg espendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg hspendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg sspendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg tspendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc l.tspendingpcl yr_*, fe cluster(country)
eststo
qui xtreg espendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc l.espendingpcl yr_*, fe cluster(country)
eststo
qui xtreg hspendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc l.hspendingpcl yr_*, fe cluster(country)
eststo
qui xtreg sspendingpcl oilreserves attempt5 coups5 civilwar5 institutions loggdppc l.sspendingpcl yr_*, fe cluster(country)
eststo
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex

*==================================
* Table 5. Total resources
*==================================
eststo clear
qui xtreg tspendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg espendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg hspendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo
qui xtreg sspendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc yr_*, fe cluster(country)
eststo 
qui xtreg tspendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc l.tspendingpcl yr_*, fe cluster(country)
eststo
qui xtreg espendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc l.espendingpcl yr_*, fe cluster(country)
eststo
qui xtreg hspendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc l.hspendingpcl yr_*, fe cluster(country)
eststo
qui xtreg sspendingpcl l.total_rent attempt5 coups5 civilwar5 institutions loggdppc l.sspendingpcl yr_*, fe cluster(country)
eststo 
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex 

***================================================================================================================================
use "SCID_Hong_dem.dta", clear

*==================================
* Table 6. Comparison to democracy
*==================================
*1. rent & export
eststo clear

qui xtreg tspendingpcl l.dem_rent loggdppc attempt5 coups5 civilwar5 yr_* , fe cluster(country)
eststo 
qui xtreg espendingpcl l.dem_rent loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.dem_rent loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.dem_rent loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg tspendingpcl l.dem_export loggdppc attempt5 coups5 civilwar5 yr_* , fe cluster(country)
eststo 
qui xtreg espendingpcl l.dem_export loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.dem_export loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.dem_export loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex 

*=========================================== 
* Table 7. Comparison to democracy (no gdp and initial gdp)
*=========================================== 

eststo clear
qui xtreg tspendingpcl l.dem_rent attempt5 coups5 civilwar5 yr_* , fe cluster(country)
eststo 
qui xtreg espendingpcl l.dem_rent attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.dem_rent attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.dem_rent attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg tspendingpcl l.dem_rent l5.loggdppc attempt5 coups5 civilwar5 yr_* , fe cluster(country)
eststo 
qui xtreg espendingpcl l.dem_rent l5.loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg hspendingpcl l.dem_rent l5.loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
qui xtreg sspendingpcl l.dem_rent l5.loggdppc attempt5 coups5 civilwar5 yr_*, fe cluster(country)
eststo 
esttab, drop(yr_*) se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) tex 


*******************************
* motivating graph  
*******************************
use "SCID_Hong_dic.dta", clear
*==========
* Figures  
*==========
twoway (scatter tspending lagoildep, color(black) graphregion(color(white)) msymbol(O) msize(small) xtitle(oil rent (% of GDP)) ytitle(social spending (% of GDP)) legend(off) jitter (20))(lfit tspending lagoildep, lwidth(thick)), saving(tspending, replace) 
twoway (scatter espending lagoildep, color(black) graphregion(color(white)) msymbol(O) msize(small) xtitle(oil rent (% of GDP)) ytitle(education spending (% of GDP)) legend(off) jitter (20))(lfit espending lagoildep, lwidth(thick)), saving(espending, replace) 
twoway (scatter hspending lagoildep, color(black) graphregion(color(white)) msymbol(O) msize(small) xtitle(oil rent (% of GDP)) ytitle(health spending (% of GDP)) legend(off) jitter (20))(lfit hspending lagoildep, lwidth(thick)), saving(hspending, replace) 
twoway (scatter sspending lagoildep, color(black) graphregion(color(white)) msymbol(O) msize(small) xtitle(oil rent (% of GDP)) ytitle(protection spending (% of GDP)) legend(off) jitter (20))(lfit sspending lagoildep, lwidth(thick)), saving(sspending, replace) 
gr combine tspending.gph espending.gph hspending.gph sspending.gph, graphregion(color(white)) saving("C:\Users\jyhong\Dropbox\Research\oil, aid and social spending\paper\spending", replace)
graph export figure.tif, width(4000)

exit
